package com.certification.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.certification.entity.ProfessionSelfEvaluation;
import com.certification.vo.ProfessionSelfEvaluationVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author copa
 * @createDate 2022-03-29 21:18
 * @function
 */
@Repository
public interface ProfessionSelfEvaluationMapper extends BaseMapper<ProfessionSelfEvaluation> {

    @Select("SELECT pse.id id, pse.first_level_point firstLevelPoint, pse.second_level_point secondLevelPoint, pse.point_desc pointDesc  " +
            "FROM profession_self_evaluation pse " +
            "LEFT JOIN certification c ON pse.cert_id = c.id " +
            "WHERE c.principal_id = #{userId} ")
    List<ProfessionSelfEvaluationVO> selectProByUserId(@Param("userId") Integer userId);

    @Select("SELECT pse.id id, pse.first_level_point firstLevelPoint, pse.second_level_point secondLevelPoint, pse.point_desc pointDesc  " +
            "FROM profession_self_evaluation pse " +
            "LEFT JOIN certification c ON pse.cert_id = c.id " +
            "WHERE c.principal_id = #{userId} AND pse.cert_id = #{certId}")
    IPage<ProfessionSelfEvaluationVO> selectProByUserIdPage(@Param("userId") Integer userId,
                                                            @Param("certId") Integer certId,
                                                            Page<ProfessionSelfEvaluationVO> page);
}
